﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DLLPC;
using DLLPC.Utilities;

namespace VisionCore
{
    public class DI_X
    {
        public byte[] Datas { get; set; }
        private int num = 0;
        private int bNum = 8;

        public DI_X(int qty = 128)
        {
            num = qty;
            List<byte> tDatas = new List<byte>();
            for (int i = 0; i < num; i++)
            {
                tDatas.Add(0);
            }
            Datas = tDatas.ToArray();
        }

        public void Update(byte[] DIStatus)
        {
            Kernel.Exc.DI.Update(DIStatus);            
        }

        public int GetCount() { return num; }

        public byte GetValIdx(int vIdx)
        {
            if (vIdx > num - 1) return 255;
            return Datas[vIdx];
        }
    }

    public class DO_Y
    {
        public byte[] Datas { get; set; }
        private int num = 0;
        private int bNum = 8;

        public DO_Y(int qty = 128)
        {
            num = qty;
            List<byte> tDatas = new List<byte>();
            for (int i = 0; i < num; i++)
            {
                tDatas.Add(0);
            }
            Datas = tDatas.ToArray();
        }

        public byte[] Update(byte[] DOStatus)
        {
            Kernel.Exc.DO.Update(DOStatus);
            return DOStatus;
        }

        public int GetCount() { return num; }

        public byte GetValIdx(int vIdx)
        {
            if (vIdx > num - 1) return 99;
            return Datas[vIdx];
        }
    }

    public class Ao_All
    {
        public float[] Datas { get; set; }
        private int num = 0;

        public Ao_All(int qty = 4)
        {
            num = qty;

            List<float> tDatas = new List<float>();
            for (int i = 0; i < num; i++)
            {
                tDatas.Add(0);
            }
            Datas = tDatas.ToArray();
        }

        public float[] Update(float[] AoStatus)
        {
            AoStatus =  Kernel.Exc.Ao.Update(AoStatus);

            return AoStatus;
        }
    }
}
